window.tywx || (window.tywx = {}),
    tywx.Util = {
        isSceneQrCode: function (e) {
            return [1047, 1048, 1049].indexOf(e) > -1;
        },
        createUUID: function () {
            for (var e = [], t = 0; t < 36; t++) e[t] = "0123456789abcdef".substr(Math.floor(16 * Math.random()), 1);
            return e[14] = "4", e[19] = "0123456789abcdef".substr(3 & e[19] | 8, 1), e[8] = e[13] = e[18] = e[23] = "",
                e.join("");
        },
        checkLocalUUID: function () {
            return "" != tywx.Util.getItemFromLocalStorage("LOCAL_UUID_KEY", "");
        },
        getLocalUUID: function () {
            var e = tywx.Util.getItemFromLocalStorage("LOCAL_UUID_KEY", "");
            return e || (e = tywx.Util.createUUID(), tywx.Util.setItemToLocalStorage("LOCAL_UUID_KEY", e)),
                e;
        },
        getItemFromLocalStorage: function (e, t) {
            try {
                if (wx && wx.getStorageSync) {
                    var n = wx.getStorageSync(e);
                    if (n) return n;
                } else {
                    var o = cc.sys.localStorage.getItem(e);
                    if (o) return o;
                }
                return t;
            } catch (e) {
                return t;
            }
        },
        setItemToLocalStorage: function (e, t) {
            try {
                wx && wx.getStorageSync ? wx.setStorage({
                    key: e,
                    data: t + ""
                }) : cc.sys.localStorage.setItem(e, t + "");
            } catch (e) {
                tywx.LOGE("tywx.Util", "setItemToLocalStorage fail");
            }
        }
    }
